nginx location 精准匹配、一般匹配 根目录"/"的例子详解
location = / {
root /var/www/html/;
index index.html;
}
location / {
root /usr/local/nginx/html;
index index.html;
}
如果访问 http://xxx.com/
定位流程是:
1. 精准匹配”/” ,得到index页为 index.html;
2. 再次访问 /index.html , 此次内部转跳uri已经是”/index.htm” , 符合一般匹配,此时根目录为/usr/local/nginx/html;
3. 最终结果,访问了/usr/local/nginx/html/index.html